﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NinjaToolbox.BattleSystem;

namespace NinjaToolbox.SubComponentModule.Example
{
    [DisallowMultipleSubComponent]
    [TargetSubComponent(typeof(DamageSubComponent))]
    [SubComponentPath("Default/DamageSubComponent")]
    [FilterKeyword("BattleObject")]
    [Rename("DamageSubComponent")]
    public class DamageSubComponent_Model : SubComponentModelBase
    {
        public int hp;
        public bool isAttackState;
        public int toEnemyDamage;
        public bool ifHasDamageSentEvent;
        public bool godMode;


        protected override void EditorSerialize(UnionSerializeWriter serializeWriter)
        {
            mSerializeVersion = 3;

            base.EditorSerialize(serializeWriter);

            serializeWriter.Write(hp);
            serializeWriter.Write(isAttackState);
            serializeWriter.Write(toEnemyDamage);
            serializeWriter.Write(ifHasDamageSentEvent);
            serializeWriter.Write(godMode);
        }

        protected override void EditorDeserialize(UnionSerializeReader serializeReader)
        {
            base.EditorDeserialize(serializeReader);

            if (mSerializeVersion < 3) return;

            hp = serializeReader.ReadInt();
            isAttackState = serializeReader.ReadBool();
            toEnemyDamage = serializeReader.ReadInt();
            ifHasDamageSentEvent = serializeReader.ReadBool();
            godMode = serializeReader.ReadBool();
        }
    }
}
